
import 'package:dk_flutter_base/dk_core.dart';
import 'package:dk_flutter_module_sale/common/user_track/user_track.dart';
import 'package:dk_flutter_module_sale/phoenix/home/bean/ui_const_bean.dart';
import 'package:dk_flutter_module_sale/phoenix/tools/widget/widget_tools_item.dart';
import 'package:flutter/material.dart';
import 'work_head_widget.dart';
import '../bean/work_home_bean.dart';

typedef OnWorkToolTap = void Function();

class WorkToolWidget extends StatelessWidget {

  final CommontoolBean commontool;
  final OnWorkToolTap  onWorkToolTap;

  WorkToolWidget(this.commontool,this.onWorkToolTap);

  @override
  Widget build(BuildContext context) {
    return Container(
        child: Stack(
        children: <Widget>[
          Container(
            width: double.infinity,
            height: 90,
            color:Color(0xff3274F9),
          ),
          Container(
            color: Colors.transparent,
            margin: const EdgeInsets.only(top: 10,left: 0,right: 0),
            child: ToolsModuleWidget(data: commontool.list,leftSpacing: 16,rightSpacing: 16,
            borderRadius: UIConstBean.CircularRadius,
            fadeInDuration: Duration(microseconds: 1),
            fadeOutDuration: Duration(microseconds: 1),
            backgroundColor: Colors.transparent,
            itemOnTap: (item){
              RouteUtil.goPage(item.appRouteUrl);
              Map<String,dynamic> map = Map<String,dynamic>();
              map["name"] = item.title;
              UserTrack.track("click_main_my_tool", map);
            },
            headChild: WorkHeadWidget(title: '常用工具',itemHeadTap: (){
              if(onWorkToolTap!= null){onWorkToolTap();
              }
            }, indicateType: HomeHeadTitleIndicateType.HomeHeadTitleIndicateLookAtMoreType,pading: EdgeInsets.only(left: 3,right: 0,top: 16),),),
          ),
        ],
      )
    );
  }
}